
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>2.1 通用约定 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="语义化.html" />
    
    
    <link rel="prev" href="HTML.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../基本原则.html">
            
                <a href="../基本原则.html">
            
                    
                    1. 基本原则
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="HTML.html">
            
                <a href="HTML.html">
            
                    
                    2. HTML
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="通用约定.html">
            
                <a href="通用约定.html">
            
                    
                    2.1 通用约定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="语义化.html">
            
                <a href="语义化.html">
            
                    
                    2.2 语义化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="HEAD.html">
            
                <a href="HEAD.html">
            
                    
                    2.3 HEAD
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../css/CSS.html">
            
                <a href="../css/CSS.html">
            
                    
                    3. CSS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../css/通用约定.html">
            
                <a href="../css/通用约定.html">
            
                    
                    3.1 通用约定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../css/字体排印.html">
            
                <a href="../css/字体排印.html">
            
                    
                    3.2 字体排印
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../css/模块组织.html">
            
                <a href="../css/模块组织.html">
            
                    
                    3.3 模块组织
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../css/Less规范.html">
            
                <a href="../css/Less规范.html">
            
                    
                    3.4 Less规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../css/性能优化.html">
            
                <a href="../css/性能优化.html">
            
                    
                    3.5 性能优化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../javascript/js.html">
            
                <a href="../javascript/js.html">
            
                    
                    4. JavaScript
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../javascript/通用约定.html">
            
                <a href="../javascript/通用约定.html">
            
                    
                    4.1. 通用约定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../javascript/jq.md">
            
                <span>
            
                    
                    4.2. jQuery 规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../javascript/性能优化.md">
            
                <span>
            
                    
                    4.3. 性能优化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../">
            
                <a href="../">
            
                    
                    5. 移动端优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../">
            
                <a href="../">
            
                    
                    6. 工具箱
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../">
            
                <a href="../">
            
                    
                    7. 参考
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >2.1 通用约定</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="21-&#x901A;&#x7528;&#x7EA6;&#x5B9A;">2.1 &#x901A;&#x7528;&#x7EA6;&#x5B9A;</h3>
<hr>
<p><strong>&#x6807;&#x7B7E;</strong></p>
<ul>
<li>&#x81EA;&#x95ED;&#x5408;&#xFF08;self-closing&#xFF09;&#x6807;&#x7B7E;&#xFF0C;&#x65E0;&#x9700;&#x95ED;&#x5408; ( &#x4F8B;&#x5982;&#xFF1A; img input br hr &#x7B49; )&#xFF1B;</li>
<li>&#x53EF;&#x9009;&#x7684;&#x95ED;&#x5408;&#x6807;&#x7B7E;&#xFF08;closing tag&#xFF09;&#xFF0C;&#x9700;&#x95ED;&#x5408; ( &#x4F8B;&#x5982;&#xFF1A;&lt;/li&gt; &#x6216; &lt;/body&gt; )&#xFF1B;</li>
<li>&#x5C3D;&#x91CF;&#x51CF;&#x5C11;&#x6807;&#x7B7E;&#x6570;&#x91CF;&#xFF1B;</li>
</ul>
<pre><code>&lt;img src=&quot;https://7n.w3cschool.cn/attachments/image/cimg/google.png&quot; alt=&quot;Google&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;title&quot;&gt;

&lt;ul&gt;
  &lt;li&gt;Style&lt;/li&gt;
  &lt;li&gt;Guide&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- Not recommended --&gt;
&lt;span class=&quot;avatar&quot;&gt;
  &lt;img src=&quot;...&quot;&gt;
&lt;/span&gt;

&lt;!-- Recommended --&gt;
&lt;img class=&quot;avatar&quot; src=&quot;...&quot;&gt;
</code></pre><p><strong>Class &#x4E0E; ID</strong></p>
<ul>
<li>class &#x5E94;&#x4EE5;&#x529F;&#x80FD;&#x6216;&#x5185;&#x5BB9;&#x547D;&#x540D;&#xFF0C;&#x4E0D;&#x4EE5;&#x8868;&#x73B0;&#x5F62;&#x5F0F;&#x547D;&#x540D;&#xFF1B;</li>
<li>class &#x4E0E; id &#x5355;&#x8BCD;&#x5B57;&#x6BCD;&#x5C0F;&#x5199;&#xFF0C;&#x591A;&#x4E2A;&#x5355;&#x8BCD;&#x7EC4;&#x6210;&#x65F6;&#xFF0C;&#x91C7;&#x7528;&#x4E2D;&#x5212;&#x7EBF;-&#x5206;&#x9694;&#xFF1B;</li>
<li>&#x4F7F;&#x7528;&#x552F;&#x4E00;&#x7684; id &#x4F5C;&#x4E3A; Javascript hook, &#x540C;&#x65F6;&#x907F;&#x514D;&#x521B;&#x5EFA;&#x65E0;&#x6837;&#x5F0F;&#x4FE1;&#x606F;&#x7684; class&#xFF1B;</li>
</ul>
<pre><code>&lt;!-- Not recommended --&gt;
&lt;div class=&quot;j-hook left contentWrapper&quot;&gt;&lt;/div&gt;

&lt;!-- Recommended --&gt;
&lt;div id=&quot;j-hook&quot; class=&quot;sidebar content-wrapper&quot;&gt;&lt;/div&gt;
</code></pre><p><strong>&#x5C5E;&#x6027;&#x987A;&#x5E8F;</strong>
HTML &#x5C5E;&#x6027;&#x5E94;&#x8BE5;&#x6309;&#x7167;&#x7279;&#x5B9A;&#x7684;&#x987A;&#x5E8F;&#x51FA;&#x73B0;&#x4EE5;&#x4FDD;&#x8BC1;&#x6613;&#x8BFB;&#x6027;&#x3002;</p>
<ul>
<li>id</li>
<li>class</li>
<li>name</li>
<li>data-xxx</li>
<li>src, for, type, href</li>
<li>title, alt</li>
<li>aria-xxx, role</li>
</ul>
<pre><code>&lt;a id=&quot;...&quot; class=&quot;...&quot; data-modal=&quot;toggle&quot; href=&quot;###&quot;&gt;&lt;/a&gt;

&lt;input class=&quot;form-control&quot; type=&quot;text&quot;&gt;

&lt;img src=&quot;...&quot; alt=&quot;...&quot;&gt;
</code></pre><ul>
<li>&#x5F15;&#x53F7;
&#x5C5E;&#x6027;&#x7684;&#x5B9A;&#x4E49;&#xFF0C;&#x7EDF;&#x4E00;&#x4F7F;&#x7528;&#x53CC;&#x5F15;&#x53F7;&#x3002;</li>
</ul>
<pre><code>&lt;!-- Not recommended --&gt;
&lt;span id=&apos;j-hook&apos; class=text&gt;Google&lt;/span&gt;

&lt;!-- Recommended --&gt;
&lt;span id=&quot;j-hook&quot; class=&quot;text&quot;&gt;Google&lt;/span&gt;
</code></pre><p><strong>&#x5D4C;&#x5957;</strong></p>
<p>a &#x4E0D;&#x5141;&#x8BB8;&#x5D4C;&#x5957; div&#x8FD9;&#x79CD;&#x7EA6;&#x675F;&#x5C5E;&#x4E8E;&#x8BED;&#x4E49;&#x5D4C;&#x5957;&#x7EA6;&#x675F;&#xFF0C;&#x4E0E;&#x4E4B;&#x533A;&#x522B;&#x7684;&#x7EA6;&#x675F;&#x8FD8;&#x6709;&#x4E25;&#x683C;&#x5D4C;&#x5957;&#x7EA6;&#x675F;&#xFF0C;&#x6BD4;&#x5982;a &#x4E0D;&#x5141;&#x8BB8;&#x5D4C;&#x5957; a&#x3002;</p>
<p>&#x4E25;&#x683C;&#x5D4C;&#x5957;&#x7EA6;&#x675F;&#x5728;&#x6240;&#x6709;&#x7684;&#x6D4F;&#x89C8;&#x5668;&#x4E0B;&#x90FD;&#x4E0D;&#x88AB;&#x5141;&#x8BB8;&#xFF1B;&#x800C;&#x8BED;&#x4E49;&#x5D4C;&#x5957;&#x7EA6;&#x675F;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x5927;&#x591A;&#x4F1A;&#x5BB9;&#x9519;&#x5904;&#x7406;&#xFF0C;&#x751F;&#x6210;&#x7684;&#x6587;&#x6863;&#x6811;&#x53EF;&#x80FD;&#x76F8;&#x4E92;&#x4E0D;&#x592A;&#x4E00;&#x6837;&#x3002;</p>
<p><strong>&#x8BED;&#x4E49;&#x5D4C;&#x5957;&#x7EA6;&#x675F;</strong></p>
<pre><code>&#xB7; &lt;li&gt; &#x7528;&#x4E8E; &lt;ul&gt; &#x6216; &lt;ol&gt; &#x4E0B;&#xFF1B;
&#xB7; &lt;dd&gt;, &lt;dt&gt; &#x7528;&#x4E8E; &lt;dl&gt; &#x4E0B;&#xFF1B;
&#xB7; &lt;thead&gt;, &lt;tbody&gt;, &lt;tfoot&gt;, &lt;tr&gt;, &lt;td&gt; &#x7528;&#x4E8E; &lt;table&gt; &#x4E0B;&#xFF1B;
</code></pre><p><strong>&#x4E25;&#x683C;&#x5D4C;&#x5957;&#x7EA6;&#x675F;</strong></p>
<pre><code>&#xB7; inline-Level &#x5143;&#x7D20;&#xFF0C;&#x4EC5;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x6587;&#x672C;&#x6216;&#x5176;&#x5B83; inline-Level &#x5143;&#x7D20;;
&#xB7; &lt;a&gt;&#x91CC;&#x4E0D;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#x4EA4;&#x4E92;&#x5F0F;&#x5143;&#x7D20;&lt;a&gt;&#x3001;&lt;button&gt;&#x3001;&lt;select&gt;&#x7B49;;
&#xB7; &lt;p&gt;&#x91CC;&#x4E0D;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#x5757;&#x7EA7;&#x5143;&#x7D20;&lt;div&gt;&#x3001;&lt;h1&gt;~&lt;h6&gt;&#x3001;&lt;p&gt;&#x3001;&lt;ul&gt;/&lt;ol&gt;/&lt;li&gt;&#x3001;&lt;dl&gt;/&lt;dt&gt;/&lt;dd&gt;&#x3001;&lt;form&gt;&#x7B49;&#x3002;
</code></pre><p>&#x66F4;&#x591A;&#x8BE6;&#x60C5;&#xFF0C;&#x53C2;&#x8003;<a href="http://www.smallni.com/element-nesting/" title="WEB&#x6807;&#x51C6;&#x7CFB;&#x5217;-HTML&#x5143;&#x7D20;&#x5D4C;&#x5957;" target="_blank">WEB&#x6807;&#x51C6;&#x7CFB;&#x5217;-HTML&#x5143;&#x7D20;&#x5D4C;&#x5957;</a></p>
<p><strong>&#x5E03;&#x5C14;&#x503C;&#x5C5E;&#x6027;</strong></p>
<p>HTML5 &#x89C4;&#x8303;&#x4E2D; disabled&#x3001;checked&#x3001;selected &#x7B49;&#x5C5E;&#x6027;&#x4E0D;&#x7528;&#x8BBE;&#x7F6E;&#x503C;&#x3002;</p>
<pre><code>&lt;input type=&quot;text&quot; disabled&gt;

&lt;input type=&quot;checkbox&quot; value=&quot;1&quot; checked&gt;

&lt;select&gt;
  &lt;option value=&quot;1&quot; selected&gt;1&lt;/option&gt;
&lt;/select&gt;
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="HTML.html" class="navigation navigation-prev " aria-label="Previous page: 2. HTML">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="语义化.html" class="navigation navigation-next " aria-label="Next page: 2.2 语义化">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"2.1 通用约定","level":"1.3.1","depth":2,"next":{"title":"2.2 语义化","level":"1.3.2","depth":2,"path":"html/语义化.md","ref":"html/语义化.md","articles":[]},"previous":{"title":"2. HTML","level":"1.3","depth":1,"path":"html/HTML.md","ref":"html/HTML.md","articles":[{"title":"2.1 通用约定","level":"1.3.1","depth":2,"path":"html/通用约定.md","ref":"html/通用约定.md","articles":[]},{"title":"2.2 语义化","level":"1.3.2","depth":2,"path":"html/语义化.md","ref":"html/语义化.md","articles":[]},{"title":"2.3 HEAD","level":"1.3.3","depth":2,"path":"html/HEAD.md","ref":"html/HEAD.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"html/通用约定.md","mtime":"2019-05-14T09:33:31.130Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-17T02:26:20.307Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

